Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix shared reference of mutable static warning #234

Merged
merged 1 commit into from
Jan 27, 2024

Conversation

jcard0na
Copy link
Contributor

This fixes this warning:

warning: shared reference of mutable static is discouraged
--> stm32l0xx-hal/src/signature.rs:45:40
|
45 | core::str::from_utf8_unchecked(&DEVICE_ID_STR)
| ^^^^^^^^^^^^^^ shared reference of mutable static
|
= note: for more information, see issue #114447 rust-lang/rust#114447
= note: reference of mutable static is a hard error from 2024 edition
= note: mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior
= note: #[warn(static_mut_ref)] on by default
help: shared references are dangerous since if there's any kind of mutation of that static while the reference lives, that's UB; use addr_of! instead to create a raw pointer

This fixes this warning:

warning: shared reference of mutable static is discouraged
  --> stm32l0xx-hal/src/signature.rs:45:40
   |
45 |         core::str::from_utf8_unchecked(&DEVICE_ID_STR)
   |                                        ^^^^^^^^^^^^^^ shared reference of mutable static
   |
   = note: for more information, see issue #114447 <rust-lang/rust#114447>
   = note: reference of mutable static is a hard error from 2024 edition
   = note: mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior
   = note: `#[warn(static_mut_ref)]` on by default
help: shared references are dangerous since if there's any kind of mutation of that static while the reference lives, that's UB; use `addr_of!` instead to create a raw pointer
@jcard0na jcard0na requested a review from a team as a code owner January 24, 2024 21:10
Copy link
Contributor

@jamwaffles jamwaffles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That whole file is... interesting :D but the fix looks good to me, thanks!

@jamwaffles jamwaffles merged commit 7132578 into stm32-rs:master Jan 27, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants